home *** CD-ROM | disk | FTP | other *** search
- #include "lib.h"
-
- /* cuserid(3)
- *
- * Author: Terrence W. Holm Sept. 1987
- */
-
- #include <stdio.h>
- #include <pwd.h>
-
- #ifndef L_cuserid
- #define L_cuserid 9
- #endif
-
- #ifdef __STDC__
- extern struct passwd *getpwuid(int);
- #else
- extern struct passwd *getpwuid();
- #endif
-
-
- char *cuserid( user_name )
- char *user_name;
-
- {
- static char userid[ L_cuserid ];
- struct passwd *pw_entry;
-
- if ( user_name == NULL )
- user_name = userid;
-
- pw_entry = getpwuid( geteuid() );
-
- if ( pw_entry == NULL )
- {
- *user_name = '\0';
- return( NULL );
- }
-
- strcpy( user_name, pw_entry->pw_name );
-
- return( user_name );
- }
-